<style>
    .layui-table-cell {
		padding:0 5px;
		height:auto;
		overflow:visible;
		text-overflow:inherit;
		white-space:normal;
		word-break: break-all;
	}
.layui-table-cell{padding:1px 3px;line-height:20px;}
.laytable-cell-1-0-0{text-align:center;}
.layui-form-pane .layui-form-label{width:auto;}
.layui-form-item{margin-bottom: 0px;}
.order-time-bg{background-color:#1E9FFF;color:white;padding:0px 5px;}
.material-status span,.material-status a{font-weight:bold;font-size:14px;}
</style>
<div class="fixed-bar">
	<form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get" id="hisi-table-search-optable" >
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">订单号</label>
				<div class="layui-input-inline">
					<input type="text" name="client_ordernum" lay-verify="" placeholder="输入订单号" class="layui-input">
				</div>
			</div>
            {if env('env_site') == 'riwei' }
            <div class="layui-inline">
                <label class="layui-form-label">客户单号</label>
                <div class="layui-input-inline">
                    <input type="text" name="ext_id" lay-verify="" placeholder="输入客户单号" class="layui-input">
                </div>
            </div>
            {/if}
			<div class="layui-inline removeStat">
				<label class="layui-form-label">SKU</label>
				<div class="layui-input-inline">
					<input type="text" name="sku" lay-verify="" placeholder="输入SKU" class="layui-input">
				</div>
			</div>
			<div class="layui-inline removeStat">
				<label class="layui-form-label">所属工厂</label>
				<div class="layui-input-inline">
					{:Form::select('factory_id', '', $factoryKV, '', '')}
				</div>
			</div>
			<div class="layui-inline removeStat">
				<label class="layui-form-label">物料状态</label>
				<div class="layui-input-inline">
					{:Form::select('order_status', '', ['' => '请选择', 1=>'面料采购未完成', 2=>'辅料采购未完成', 3=>'换料中', 4=>'批色不通过',5=>'面料已到料',6=>'已批色'], '', '')}
				</div>
			</div>
			<div class="layui-inline removeStat">
				<label class="layui-form-label">下单日期</label>
				<div class="layui-input-inline">
					<input type="text" name="create_date_range" readonly="" id="create_date_range" lay-verify="" placeholder="选择下单日期" class="layui-input">
				</div>
			</div>
            <div class="layui-inline removeStat">
                  <label class="layui-form-label">账号</label>
                    <div class="layui-input-inline">
                        {:Form::select('is_auto_import', '', $orderFrom, '', '')}
                    </div>
            </div>
			<div class=" layui-inline layui-upload">
				<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1" >搜索</button>
				<button type="button" id="btn" class="layui-btn layui-btn-primary hisi-export prescription">导出</button>
			</div>
		</div>
	</form>
</div>
<!-- 进度统计 -->
    <div class="layui-collapse removeStat" lay-accordion>
      <div class="layui-colla-item">
        <h2 class="layui-colla-title">数据统计</h2>
        <div class="layui-colla-content layui-show1">
          <table class="layui-table">
            <thead>
              <tr>
                <th>不含尾货</th>
                <th>下单数</th>
                <th>面料采购已完成单数</th>
                <th>换料中单数</th>
                <th>面料采购未完成单数</th>
                <th>已批色单数</th>
                <th>未批色单数</th>
                <th>批色不通过单数</th>
                <th>已验布缩水单数</th>
                <th>未验布缩水单数</th>
                <th>已裁单数</th>
                <th>未裁单数</th>
                <th>辅料发放单数</th>
                <th>辅料未发放单数</th>
                <th>辅料采购未完成</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>单数</td>
                <td><a href="{:url()}?a=stat&sc=allCount" class="ac-item hisi-iframe" title="下单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=fabricCgOverCount" class="stat-fcoc-item hisi-iframe" title="面料采购已完成单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=returnMaterialCount" class="stat-rmc-item hisi-iframe" title="退料中单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=fabricCgNotCount" class="stat-fcnc-item hisi-iframe" title="面料采购未完成单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=apColorOverCount" class="stat-acoc-item hisi-iframe" title="已批色通过单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=apColorNotCount" class="stat-acnc-item hisi-iframe" title="未批色单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=apColorNoCount" class="stat-acnoc-item hisi-iframe" title="批色不通过单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=ckClothSkOverCount" class="stat-csoc-item hisi-iframe" title="已验布缩水单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=ckClothSkNotCount" class="stat-csnc-item hisi-iframe" title="未验布缩水单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=caichuangOverCount" class="stat-coc-item hisi-iframe" title="已裁单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=caichuangNotCount" class="stat-cnc-item hisi-iframe" title="未裁单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=acOverCount" class="stat-aoc-item hisi-iframe" title="辅料发放单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=acNotCount" class="stat-anc-item hisi-iframe" title="待领料单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=acNoCount" class="stat-acNoCount-item hisi-iframe" title="辅料采购未完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
              </tr>
              <tr>
                <td>完成率</td>
                <td class=""></td>
                <td class="stat-fcocp-item">0%</td>
                <td class="stat-rmcp-item">0%</td>
                <td class="stat-fncp-item">0%</td>
                <td class="stat-acocp-item">0%</td>
                <td class="stat-acncp-item">0%</td>
                <td class="stat-acnocp-item">0%</td>
                <td class="stat-csocp-item">0%</td>
                <td class="stat-csncp-item">0%</td>
                <td class="stat-cocp-item">0%</td>
                <td class="stat-cncp-item">0%</td>					
                <td class="stat-aocp-item">0%</td>
                <td class="stat-ancp-item">0%</td>
                <td class="stat-acNoCountp-item">0%</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>

<div class="layui-tab layui-tab-card">
  <ul class="layui-tab-title">
    <li class="layui-this">时效统计</li>
<!--    <li>财务时效统计</li>-->
  </ul>
  <div class="layui-tab-content">
      <div class="layui-tab-item layui-show">
            <!-- 订单时效统计 -->
            <div class="layui-collapse removeStat" lay-accordion>
              <div class="layui-colla-item">
                <h2 class="layui-colla-title">订单时效统计</h2>
                <div class="layui-colla-content layui-show1">
                  <table class="layui-table">
                    <thead>
                      <tr>
                        <th rowspan="2">不含尾货</th>
                        <th colspan="2">采购时效</th>
                        <th colspan="2">裁前时效</th>
                        <th colspan="2">裁床时效</th>
                        <th colspan="2">缝前时效</th>   
                      </tr>
                      <tr>
                        <th>单数</th>
                        <th>百分比</th>
                        <th>单数</th>
                        <th>百分比</th>
                        <th>单数</th>
                        <th>百分比</th>
                        <th>单数</th>
                        <th>百分比</th>
                      </tr>
                    </thead>
                    <tbody class="order">
                      <tr>
                        <td>一天内完成</td>
                        <td><a class="caig_day1 hisi-iframe" title="采购一天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caig_day1p">0%</td>
                        <td><a class="caicb_day1 hisi-iframe" title="裁前一天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caicb_day1p">0%</td>
                        <td><a class="caic_day1 hisi-iframe" title="裁床一天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caic_day1p">0%</td>
                        <td><a class="chejb_day1 hisi-iframe" title="缝前一天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="chejb_day1p">0%</td>
                      </tr>
                      <tr>
                        <td>两天内完成</td>
                        <td><a class="caig_day2 hisi-iframe" title="采购两天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caig_day2p">0%</td>
        <!--                <td class="checkc_day2">0</td>
                        <td class="checkc_day2p">0%</td>
                        <td class="shrink_day2">0</td>
                        <td class="shrink_day2p">0%</td>-->
                        <td><a class="caicb_day2 hisi-iframe" title="裁前两天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caicb_day2p">0%</td>
                        <td><a class="caic_day2 hisi-iframe" title="裁床两天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caic_day2p">0%</td>
                        <td><a class="chejb_day2 hisi-iframe" title="缝前两天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="chejb_day2p">0%</td>
                      </tr>
                      <tr>
                        <td>三天内完成</td>
                        <td><a class="caig_day3 hisi-iframe" title="采购三天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caig_day3p">0%</td>
        <!--                <td class="checkc_day3">0</td>
                        <td class="checkc_day3p">0%</td>
                        <td class="shrink_day3">0</td>
                        <td class="shrink_day3p">0%</td>-->
                        <td><a class="caicb_day3 hisi-iframe" title="裁前三天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caicb_day3p">0%</td>
                        <td><a class="caic_day3 hisi-iframe" title="裁床三天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caic_day3p">0%</td>
                        <td><a class="chejb_day3 hisi-iframe" title="缝前三天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="chejb_day3p">0%</td>
                      </tr>
                      <tr>
                        <td>四天内完成</td>
                        <td><a class="caig_day4 hisi-iframe" title="采购四天内完成"  hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caig_day4p">0%</td>
        <!--                <td class="checkc_day4">0</td>
                        <td class="checkc_day4p">0%</td>
                        <td class="shrink_day4">0</td>
                        <td class="shrink_day4p">0%</td>-->
                        <td><a class="caicb_day4 hisi-iframe" title="裁前四天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caicb_day4p">0%</td>
                        <td><a class="caic_day4 hisi-iframe" title="裁床四天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caic_day4p">0%</td>
                        <td><a class="chejb_day4 hisi-iframe" title="缝前四天内完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="chejb_day4p">0%</td>
                      </tr>
                      <tr>
                        <td>四天以上完成</td>
                        <td><a class="caig_than_day4 hisi-iframe" title="采购四天以上完成"  hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caig_than_day4p">0%</td>
        <!--                <td class="checkc_than_day4">0</td>
                        <td class="checkc_than_day4p">0%</td>
                        <td class="shrink_than_day4">0</td>
                        <td class="shrink_than_day4p">0%</td>-->
                        <td><a class="caicb_than_day4 hisi-iframe" title="裁前四天以上完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caicb_than_day4p">0%</td>
                        <td><a class="caic_than_day4 hisi-iframe" title="裁床四天以上完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caic_than_day4p">0%</td>
                        <td><a class="chejb_than_day4 hisi-iframe" title="缝前四天以上完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="chejb_than_day4p">0%</td>
                      </tr>
                      <tr>
                        <td>未完成</td>
                        <td><a class="caig_not_compelte hisi-iframe" title="采购未完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caig_not_compeltep">0%</td>
        <!--                <td class="checkc_than_day4">0</td>
                        <td class="checkc_than_day4p">0%</td>
                        <td class="shrink_than_day4">0</td>
                        <td class="shrink_than_day4p">0%</td>-->
                        <td><a class="caicb_not_compelte hisi-iframe" title="裁前未完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caicb_not_compeltep">0%</td>
                        <td><a class="caic_not_compelte hisi-iframe" title="裁床未完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="caic_not_compeltep">0%</td>
                        <td><a class="chejb_not_compelte hisi-iframe" title="缝前未完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="chejb_not_compeltep">0%</td>
                      </tr>
                      <tr>
                        <th>平均时效</th>
                        <th class="caig_avg" colspan="2">0</th>
        <!--                <th class="checkc_avg" colspan="2">0</th>
                        <th class="shrink_avg" colspan="2">0</th>-->
                        <th class="caicb_avg" colspan="2">0</th>
                        <th class="caic_avg" colspan="2">0</th>
                        <th class="chejb_avg" colspan="2">0</th>
                      </tr>
                      
                      
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
            <!-- 物料时效统计 -->
            <div class="layui-collapse removeStat" lay-accordion>
              <div class="layui-colla-item">
                <h2 class="layui-colla-title">物料时效统计</h2>
                <div class="layui-colla-content layui-show1">
                  <table class="layui-table">
                    <thead>
                      <tr>
                        <th rowspan="2">不含尾货</th>
                        <th colspan="2">面料打标时效</th>
                        <th colspan="2">辅料打标时效</th>
                        <th colspan="2">批色时效</th>
                        <th colspan="2">验布时效</th>
                        <th colspan="2">缩水时效</th>
                      </tr>
                      <tr>
                        <th>数量</th>
                        <th>百分比</th>
                        <th>数量</th>
                        <th>百分比</th>
                        <th>数量</th>
                        <th>百分比</th>
                        <th>数量</th>
                        <th>百分比</th>
                        <th>数量</th>
                        <th>百分比</th>
                      </tr>
                    </thead>
                    <tbody class="order">
                      <tr>
                        <td>12小时内完成</td>
                        <td><a class="fmg_time12 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="fmg_time12p">0%</td>
                        <td><a class="amg_time12 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="amg_time12p">0%</td>
                        <td><a class="ap_time12 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="ap_time12p">0%</td>
                        <td><a class="checkc_time12 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="checkc_time12p">0%</td>
                        <td><a class="shrink_time12 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="shrink_time12p">0%</td>
                      </tr>
                      <tr>
                        <td>24小时内完成</td>
                        <td><a class="fmg_time24 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="fmg_time24p">0%</td>
                        <td><a class="amg_time24 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="amg_time24p">0%</td>
                        <td><a class="ap_time24 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="ap_time24p">0%</td>
                        <td><a class="checkc_time24 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="checkc_time24p">0%</td>
                        <td><a class="shrink_time24 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="shrink_time24p">0%</td>
                      </tr>
                      <tr>
                        <td>36小时内完成</td>
                        <td><a class="fmg_time36 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="fmg_time36p">0%</td>
                        <td><a class="amg_time36 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="amg_time36p">0%</td>
                        <td><a class="ap_time36 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="ap_time36p">0%</td>
                        <td><a class="checkc_time36 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="checkc_time36p">0%</td>
                        <td><a class="shrink_time36 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="shrink_time36p">0%</td>
                      </tr>
                      <tr>
                        <td>48小时内完成</td>
                        <td><a class="fmg_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="fmg_time48p">0%</td>
                        <td><a class="amg_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="amg_time48p">0%</td>
                        <td><a class="ap_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="ap_time48p">0%</td>
                        <td><a class="checkc_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="checkc_time48p">0%</td>
                        <td><a class="shrink_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="shrink_time48p">0%</td>
                      </tr>
                      <tr>
                        <td>48小时以上完成</td>
                        <td><a class="fmg_than_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="fmg_than_time48p">0%</td>
                        <td><a class="amg_than_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="amg_than_time48p">0%</td>
                        <td><a class="ap_than_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="ap_than_time48p">0%</td>
                        <td><a class="checkc_than_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="checkc_than_time48p">0%</td>
                        <td><a class="shrink_than_time48 hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="shrink_than_time48p">0%</td>
                      </tr>
                      <tr>
                        <td>未完成</td>
                        <td><a class="fmg_not_compelte hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="fmg_not_compeltep">0%</td>
        <!--                <td class="checkc_than_day4">0</td>
                        <td class="checkc_than_day4p">0%</td>
                        <td class="shrink_than_day4">0</td>
                        <td class="shrink_than_day4p">0%</td>-->
                        <td><a class="amg_not_compelte hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="amg_not_compeltep">0%</td>
                        <td><a class="ap_not_compelte hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="ap_not_compeltep">0%</td>
                        <td><a class="checkc_not_compelte hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="checkc_not_compeltep">0%</td>
                        <td><a class="shrink_not_compelte hisi-iframe" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                        <td class="shrink_not_compeltep">0%</td>
                      </tr>
                      <tr>
                        <th>平均时效</th>
                        <th class="fmg_avg" colspan="2">0</th>
                        <th class="amg_avg" colspan="2">0</th>
                        <th class="ap_avg" colspan="2">0</th>
                        <th class="checkc_avg" colspan="2">0</th>
                        <th class="shrink_avg" colspan="2">0</th>
                      </tr>
                      </tbody>
                  </table>
                </div>
              </div>
            </div>
      </div>
      <div class="layui-tab-item">
            3333
      </div>
  </div>
</div>



<table id="dataTable" lay-filter='dataTable'></table>

{include file="system@block/layui" /}

<script type="text/html" id="picTpl">
    <span class="lay-pic-container" src="{{ d.sInfo.pic }}">
		<img src="{{ d.sInfo.ori_pic }}" class="lay-pic">
		{{# if(d.status==99){ }}
			<span class="sign"><img src="/static/system/image/sign_delete.png"></span>
		{{# }else if(d.status==2){ }}
			<span class="sign"><img src="/static/system/image/sign_over.png"></span>
		{{# }else if(d.tail_status==1){ }}
			<span class="sign"><img src="/static/system/image/sign_tail.png"></span>
		{{# }else if(d.chejian_status==1){ }}
			<span class="sign"><img src="/static/system/image/sign_workshop.png"></span>
		{{# }else if(d.caichuang_status==1){ }}
			<span class="sign"><img src="/static/system/image/sign_cutting.png"></span>
		{{# }else if(d.caigou_status==1){ }}
			<span class="sign"><img src="/static/system/image/sign_purchasing_done.png"></span>
		{{# }else { }}
			<span class="sign"><img src="/static/system/image/sign_purchasing_todo.png"></span>
		{{# } }}
	</span>
</script>
<script type="text/html" id="skuTpl">
    <span class="copy-item">{{ d.client_ordernum }}</span> <span class="layui-badge layui-bg-blue">{{ layui.tool.formatOrderOType(d.o_type) }}</span><span class="layui-badge layui-bg-orange">{{ layui.tool.formatOrderType(d.type) }}</span><br>
    {if env('env_site') == 'riwei' }
    <span class="copy-item">{{ d.ext_id }}</span> <br>
    {/if}
    <span class="copy-item">{{ d.sku }}</span> <br>
    {{ d.shipment_time_diff }} <br>
    {{ d.create_time_diff }} <br>
    {{# if(d.status == 99){ }}<span class="layui-badge">{{ d.delete_text }}</span> {{# } }}
    {{ orderFrom[d.is_auto_import] }}
</script>
<script type="text/html" id="factoryTpl">
    {{ d.factory_name }} <br>
    {{ d.group_name }} <br>
	{{# if(d.outgo_status > 0){ }}
		外发：{{ d.factory_outgo_name }}
	{{# } }}

</script>
<script type="text/html" id="skuStockTpl">
	{{# if(d.skuStock.length>0){ var all_stock_count=0; }}
		<div style="writing-mode: tb-rl;float:left;width:28px;padding-top:10px;letter-spacing:4px;font-weight:bold;color:red;">可用库存</div>
		<div style="margin-left:30px;">
		{{# for(var i in d.skuStock){ all_stock_count+=parseInt(d.skuStock[i].available_count); }}
			{{ d.skuStock[i].size_name }}： {{ d.skuStock[i].available_count }} <br>
		{{# } }}
			总：{{all_stock_count}}
		</div>
	{{# } }}
</script>
<script type="text/html" id="orderNumTpl">
	{{# for(var i in d.osList){ }}
    	{{ d.osList[i].size_name }}： <span title="下单数">{{ d.osList[i].order_count }}</span> / <span title="裁床数">{{ d.osList[i].shicai_count }}</span> / <span title="车间数">{{ d.osList[i].jiaohuo_count }}</span> / <span title="后整数">{{ d.osList[i].jiaohuo_tail_count }}</span> / <span title="打包数">{{ d.osList[i].delivery_count }}</span> / <span title="出货数">{{ d.osList[i].daohuo_count }}</span> <br>
	{{# } }}
	总数：<span title="总下单数">{{ d.osStat.order_count }}</span> / <span title="总裁床数">{{ d.osStat.shicai_count }}</span> / <span title="总车间数">{{ d.osStat.jiaohuo_count }}</span> / <span title="总后整数">{{ d.osStat.jiaohuo_tail_count }}</span> / <span title="总打包数">{{ d.osStat.delivery_count }}</span> / <span title="总出货数">{{ d.osStat.daohuo_count }}</span>
</script>
<script type="text/html" id="orderTimeTpl">
    <div class="{{# if(d.create_time > 0){ }}order-time-bg{{# } }}">下单：{{# if(d.create_time > 0){ }} {{ layui.util.toDateString(d.create_time * 1000) }} {{# } }}</div>
	<div class="{{# if(d.shipment_time > 0){ }}order-time-bg{{# } }}">货期：{{# if(d.shipment_time > 0){ }} {{ layui.util.toDateString(d.shipment_time * 1000) }} {{# } }}</div>    
	<div class="{{# if(d.caigou_over_time > 0){ }}order-time-bg{{# } }}">采购：{{# if(d.caigou_over_time > 0){ }} {{ layui.util.toDateString(d.caigou_over_time * 1000) }} {{# } }}</div>
    <div class="{{# if(d.caichuang_over_time > 0){ }}order-time-bg{{# } }}">裁床：{{# if(d.caichuang_over_time > 0){ }} {{ layui.util.toDateString(d.caichuang_over_time * 1000) }} {{# } }}</div>
    <div class="{{# if(d.chejian_over_time > 0){ }}order-time-bg{{# } }}">车间：{{# if(d.chejian_over_time > 0){ }} {{ layui.util.toDateString(d.chejian_over_time * 1000) }} {{# } }}</div>
    <div class="{{# if(d.tail_over_time > 0){ }}order-time-bg{{# } }}">尾部：{{# if(d.tail_over_time > 0){ }} {{ layui.util.toDateString(d.tail_over_time * 1000) }} {{# } }}</div>
    <div class="{{# if(d.over_time > 0){ }}order-time-bg{{# } }}">总完：{{# if(d.over_time > 0){ }} {{ layui.util.toDateString(d.over_time * 1000) }} {{# } }}</div>
</script>
<script type="text/html" id="orderUserTpl">
	{{# if(d.caigou_status==1){ }}
		{{ d.caigou_user_name }} 
	{{# }else{ }}
		{{ layui.tool.showSelect('caigou_user_id', d.caigou_user_id, purchasingUserKV, 'caigou-user', d.id) }}
	{{# } }}

</script>
<script type="text/html" id="buttonTpl">
	<div style="line-height:35px;">
		{{# if(d.caigou_status==0){ }}
			<a href="{:url('approvalColor')}?order_id={{ d.id }}&mid=0" title="全部批色" class="layui-btn layui-btn-sm hisi-ajax layui-btn-warm approval-color-{{ d.id }}" confirm="您确定要执行该操作吗？" refresh="false" callback="callbackApprovalColor">全部批色</a><br>
		{{# } }}
	</div>
    <a href="{:url('updateCaichuangCanDo')}?order_id={{ d.id }}" title="更新裁剪状态" class="layui-btn layui-btn-sm hisi-ajax" refresh="false">更新裁剪状态</a><br>
</script>


<script type="text/html" title="余料使用量" id="subMaterialUseTpl">
	{{# if(d.mInfo.type=='accessories'){ }}
		{{ d.stock_use_num }}
	{{# }else{ }}
        {{ d.apply_and_used.apply }} / {{ d.apply_and_used.have_metres }}
		{{# if(d.apply_and_used.apply > 0 || d.apply_and_used.have_metres >0){ }}
			<a href="{:url('materialStock/apply')}?material_id={{ d.material_id }}&client_ordernum={{ d.p.client_ordernum }}" title="余料占用" class="layui-btn layui-btn-normal layui-btn-sm hisi-iframe" hisi-data="{width: '800px', height: '500px'}">占用</a>
		{{# } }}
	{{# } }}
</script>

<script type="text/html" title="还需用量" id="needNumTpl">
	{{# if(d.mInfo.type=='accessories'){ }}
		{{ layui.tool.bcsub(d.total_material_dosage, d.stock_use_num) }}
	{{# }else{ }}
		{{ layui.tool.bcsub(d.total_material_dosage, (d.apply_and_used.apply + d.apply_and_used.used)) }}
	{{# } }}
</script>

<script type="text/html" title="打标日志" id="shijiCaigouTpl">
	{{# if(d.shiji_caigou_count!=''){ }}
		<a href="{:url('makeTagLog')}?mid={{ d.mid }}" title="总条数" class="hisi-iframe" hisi-data="{width: '800px', height: '500px'}">{{ d.shiji_caigou_count }}</a>
	{{# } }}
</script>
<script type="text/html" title="来退料明细" id="tiaoshuDetailTpl">
	{{# if(d.tiaoshu_detail!=''){ }}
		<a href="{:url('materialLog')}?mid={{ d.mid }}" title="来退料明细" class="hisi-iframe" hisi-data="{width: '500px', height: '400px'}">{{ d.tiaoshu_detail }}</a>
	{{# } }}
</script>

<script type="text/html" title="物料状态" id="purchasingStatusTpl">
<div class="material-status material-status-{{ d.mid }}">
	{{# if(d.mInfo.type!='accessories' && d.material_status.is_make_tag==1 && d.material_status.is_caigou_start==2 && d.material_status.is_checkcloth!=1 && d.material_status.is_shrink!=1 && d.material_status.material_return!=1 && d.caigou_status==1){ }}
		<span class="green">可裁剪</span>
	{{# }else{ }}
		
		{{# if(d.material_status.is_caigou_start==0){ }}
			{{# if(d.mInfo.type=='accessories'){ }}
				<a href="javascript:void(0)" data-material_id="{{ d.material_id }}" data-mid="{{ d.mid }}" data-order_id="{{ d.order_id }}" title="开始采购" class="orange start-purchasing">开始采购</a>
			{{# }else{ }}
				<a href="javascript:void(0)" data-mid="{{ d.mid }}" data-order_id="{{ d.order_id }}" data-material_id="{{ d.material_id }}" data-order_from="{{ orderFrom[d.p.is_auto_import] }}" data-client_ordernum="{{ d.client_ordernum }}" data-name="{{ d.mInfo.name }}" data-colornum="{{ d.mInfo.colornum }}" data-color="{{ d.mInfo.color }}" data-num="{{ d.total_material_dosage - d.apply_and_used.apply - d.apply_and_used.used }}" data-model="{{ d.mInfo.model }}" data-weight="{{d.weight}}" data-sku="{{ d.sku }}" title="开始采购" class="orange start-purchasing-metre">开始采购</a>
			{{# } }}
		{{# }else if(d.material_status.is_caigou_start==1){ }}
			<span class="red">采购中</span>
		{{# }else{ }}
			<span class="green">采购完成</span>
		{{# } }}

		&nbsp;&nbsp;

		{{# if(d.material_status.material_return==1){ }}
			<span class="red">换料中</span>
		{{# }else if(d.material_status.material_return==2){ }}
			<span class="green">换料完成</span>
		{{# } }}

		{{# if(d.mInfo.type!='accessories'){ }}
			<br>
			{{# if(d.material_status.is_checkcloth==0){ }}
				<span class="green">无需验布</span>
			{{# }else if(d.material_status.is_checkcloth==1){ }}
				<span class="red">验布中</span>
			{{# }else{ }}
				<span class="green">验布完成</span>
			{{# } }}
		
			&nbsp;&nbsp;		

			{{# if(d.material_status.is_shrink==0 || d.factory_id==14){ }}
				<span class="green">无需缩水</span>
			{{# }else if(d.material_status.is_shrink==1){ }}
				<span class="red">缩水中</span>
			{{# }else{ }}
				<span class="green">缩水完成</span>
			{{# } }}

		{{# } }}
	{{# } }}
</div>
</script>
<script type="text/html" title="余量/占用量" id="leftUseTpl">
	{{# if(d.mInfo.type=='accessories'){ }}
		<span class="stock-{{ d.mid }}">{{ d.stock_left }}</span> / {{ d.stock_use_num }}
	{{# }else{ }}
		<span class="stock-{{ d.mid }}">{{ d.metre_left }}</span> / {{ d.apply_and_used.apply }}
	{{# } }}
</script>
<script type="text/html" title="按钮组" id="subButtonTpl">
	<div style="line-height:35px;">
        
        {{# if(d.arrive_time==0){ }}
        <a href="javascript:void(0)" onclick="arriveTime({{ d.mid }})" title="到料" data-mid="{{ d.mid }}" data-order_id="{{ d.order_id }}" class="layui-btn layui-btn-sm  arrive-time arrive-time-{{ d.mid }}">到料</a>
        {{# }else{ }}		
            <a href="javascript:void(0)" onclick="arriveTime({{ d.mid }})" title="更新" data-mid="{{ d.mid }}" data-order_id="{{ d.order_id }}" class="layui-btn layui-btn-sm layui-btn-warm arrive-time arrive-time-{{ d.mid }}">更新</a>
        {{# } }}
		<a href="javascript:void(0)" title="打标" style="{{# if(d.arrive_time==0){ }}display:none {{# } }}" data-mid="{{ d.mid }}" class="layui-btn layui-btn-sm layui-btn-primary make-tag make-tag-{{ d.mid }}">打标</a> 
		
		{{# if(d.mInfo.type!='accessories'){ }}
			{{# if(d.caigou_status==0){ }}
				<a href="javascript:void(0)" title="未批色" data-mid={{ d.mid }} data-order_id={{ d.order_id }} class="layui-btn layui-btn-sm layui-btn-warm approval-color approval-color-{{ d.mid }}">未批色</a>
			{{# }else if(d.caigou_status==2){ }}		
				<a href="javascript:void(0)" title="批色未通过" data-mid={{ d.mid }} data-order_id={{ d.order_id }} class="layui-btn layui-btn-sm layui-btn-warm approval-color approval-color-{{ d.mid }}">批色未通过</a>
			{{# } }}
		{{# } }}

		{{# if(d.mInfo.type=='accessories'){ }}
			<a href="{:url('stock/add')}?client_ordernum={{ d.p.client_ordernum }}&material_sku={{ d.mInfo.material_sku }}&mid={{ d.mid }}&_t=2" class="layui-btn layui-btn-sm hisi-iframe" hisi-data="{width: '500px', height: '500px'}" title="辅料入库">入库</a>
		{{# }else{ }}
			<a href="{:url('materialStock/add')}?client_ordernum={{ d.p.client_ordernum }}&material_sku={{ d.mInfo.material_sku }}&mid={{ d.mid }}&_t=2" class="layui-btn layui-btn-sm hisi-iframe" hisi-data="{width: '500px', height: '500px'}" title="余料入库">入库</a>
		{{# } }}
		<a href="{:url('returnClothnum')}?mid={{ d.mid }}" title="退料" class="layui-btn layui-btn-sm layui-btn-normal hisi-iframe" hisi-data="{width: '900px', height: '500px'}">退料</a>
	</div>
</script>

<div id="approvalColorTpl" style="display:none;" class="pt20 pl20">
	<form class="layui-form layui-form-pane" lay-verify="" action="" method="get">
	<div class="layui-form-item">	
		<div class="layui-inline">
			<label class="layui-form-label">批色结果</label>
			<div class="layui-input-inline">
				{:Form::radio('status', 1, ['1' => '通过', '2'=>'不通过'], '', '')}
			</div>
		</div>
	</div>
	</form>
</div>

<div id="makeTagTpl" style="display:none;" class="pt20 pl20">
	<form class="layui-form layui-form-pane" lay-verify="" action="" method="get">
	<div class="layui-form-item">	
		<div class="layui-inline">
			<label class="layui-form-label">打标条数</label>
			<div class="layui-input-inline">
				<input type="text" name="number" lay-verify="number|required" placeholder="输入条数" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">备注</label>
			<div class="layui-input-inline">
				<input type="text" name="remark" lay-verify="required" placeholder="输入备注" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">档口</label>
			<div class="layui-input-inline stall-select">
                {:Form::select('stalls_id','' , $stallsKV, 'stall-ids', 'layui-input','lay-search="" lay-verify="required"')}
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">是否库存</label>
			<div class="layui-input-inline">
				{:Form::radio('is_from_stock', '', ['0' => '否', 1=>'是'], '', '')}
			</div>
		</div>
        <div class="layui-inline">
			<label class="layui-form-label">是否共用</label>
			<div class="layui-input-inline">
				{:Form::radio('is_share', '', ['0' => '否', 1=>'是'], '', '')}
			</div>
		</div>
	</div>
	</form>
</div>

<script type="text/javascript">
  
	var purchasingUserKV = {:json_encode($purchasingUserKV);};
	var systemUserKV = {:json_encode($systemUserKV);};
	var orderFrom = {:json_encode($orderFrom);};
	systemUserKV['0'] = '请选择';
	layui.use(['upload', 'opTable', 'jquery', 'tool', 'laydate', 'layer', 'form', 'laytpl'], function() {
		var $ = layui.jquery;
		var laydate = layui.laydate;
		var laytpl = layui.laytpl;
		var layer = layui.layer;
		var form = layui.form;
        var upload = layui.upload;
        $('.stall-select').click(function(){
            $('.stall-select input').val("");
        }); 
        form.on('submit(demo1)', function (data) {
            var formData = data.field;
            //console.log(formData);
            $.ajax({
                type: "POST",
                url: "{:url('timeStatistics')}",
                data: formData,
                dataType:"json",
                success: function(res){
                    var o=res.order,m=res.material;
                    //采购时效
                    function percent(num){
                        b=num/o.day_caigou.dayCount ? num/o.day_caigou.dayCount:0;
                        a=(b).toFixed(2);
                        return a;
                    }
                    $('.caig_day1').html(o.day_caigou.oneDay);$('.caig_day1').attr('href','{:url()}?a=stat&orders='+o.day_caigou.order1);
                    $('.caig_day1p').html((percent(o.day_caigou.oneDay)*100).toFixed(0)+'%');
                    $('.caig_day2').html(o.day_caigou.twoDay);$('.caig_day2').attr('href','{:url()}?a=stat&orders='+o.day_caigou.order2);
                    $('.caig_day2p').html((percent(o.day_caigou.twoDay)*100).toFixed(0)+'%');
                    $('.caig_day3').html(o.day_caigou.threeDay);$('.caig_day3').attr('href','{:url()}?a=stat&orders='+o.day_caigou.order3);
                    $('.caig_day3p').html((percent(o.day_caigou.threeDay)*100).toFixed(0)+'%');
                    $('.caig_day4').html(o.day_caigou.fourDay);$('.caig_day4').attr('href','{:url()}?a=stat&orders='+o.day_caigou.order4);
                    $('.caig_day4p').html((percent(o.day_caigou.fourDay)*100).toFixed(0)+'%');
                    $('.caig_than_day4').html(o.day_caigou.thanFourDay);$('.caig_than_day4').attr('href','{:url()}?a=stat&orders='+o.day_caigou.orderThan4);
                    $('.caig_than_day4p').html((percent(o.day_caigou.thanFourDay)*100).toFixed(0)+'%');//
                    $('.caig_avg').html(o.day_caigou.aveDay);
                    $('.caig_not_compelte').html(o.day_caigou.notCompleteCount);$('.caig_not_compelte').attr('href','{:url()}?a=stat&orders='+o.day_caigou.notCompleteOrder);
                    $('.caig_not_compeltep').html((percent(o.day_caigou.notCompleteCount)*100).toFixed(0)+'%');
                    //验布时效
//                    $('.checkc_day1').html(o.day_checkcloth.oneDay);
//                    $('.checkc_day1p').html(percent(o.day_checkcloth.oneDay)*100+'%');
//                    $('.checkc_day2').html(o.day_checkcloth.twoDay);
//                    $('.checkc_day2p').html(percent(o.day_checkcloth.twoDay)*100+'%');
//                    $('.checkc_day3').html(o.day_checkcloth.threeDay);
//                    $('.checkc_day3p').html(percent(o.day_checkcloth.threeDay)*100+'%');
//                    $('.checkc_day4').html(o.day_checkcloth.fourDay);
//                    $('.checkc_day4p').html(percent(o.day_checkcloth.fourDay)*100+'%');
//                    $('.checkc_than_day4').html(o.day_checkcloth.thanFourDay);
//                    $('.checkc_than_day4p').html(percent(o.day_checkcloth.thanFourDay)*100+'%');
//                    $('.checkc_avg').html(o.day_checkcloth.aveDay);
                    //缩水时效
//                    $('.shrink_day1').html(o.day_shrink.oneDay);
//                    $('.shrink_day1p').html(percent(o.day_shrink.oneDay)*100+'%');
//                    $('.shrink_day2').html(o.day_shrink.twoDay);
//                    $('.shrink_day2p').html(percent(o.day_shrink.twoDay)*100+'%');
//                    $('.shrink_day3').html(o.day_shrink.threeDay);
//                    $('.shrink_day3p').html(percent(o.day_shrink.threeDay)*100+'%');
//                    $('.shrink_day4').html(o.day_shrink.fourDay);
//                    $('.shrink_day4p').html(percent(o.day_shrink.fourDay)*100+'%');
//                    $('.shrink_than_day4').html(o.day_shrink.thanFourDay);
//                    $('.shrink_than_day4p').html(percent(o.day_shrink.thanFourDay)*100+'%');
//                    $('.shrink_avg').html(o.day_shrink.aveDay);
                    //裁前时效
                    $('.caicb_day1').html(o.day_caichuang_before.oneDay);$('.caicb_day1').attr('href','{:url()}?a=stat&orders='+o.day_caichuang_before.order1);
                    $('.caicb_day1p').html((percent(o.day_caichuang_before.oneDay)*100).toFixed(0)+'%');
                    $('.caicb_day2').html(o.day_caichuang_before.twoDay);$('.caicb_day2').attr('href','{:url()}?a=stat&orders='+o.day_caichuang_before.order2);
                    $('.caicb_day2p').html((percent(o.day_caichuang_before.twoDay)*100).toFixed(0)+'%');
                    $('.caicb_day3').html(o.day_caichuang_before.threeDay);$('.caicb_day3').attr('href','{:url()}?a=stat&orders='+o.day_caichuang_before.order3);
                    $('.caicb_day3p').html((percent(o.day_caichuang_before.threeDay)*100).toFixed(0)+'%');
                    $('.caicb_day4').html(o.day_caichuang_before.fourDay);$('.caicb_day4').attr('href','{:url()}?a=stat&orders='+o.day_caichuang_before.order4);
                    $('.caicb_day4p').html((percent(o.day_caichuang_before.fourDay)*100).toFixed(0)+'%');
                    $('.caicb_than_day4').html(o.day_caichuang_before.thanFourDay);$('.caicb_than_day4').attr('href','{:url()}?a=stat&orders='+o.day_caichuang_before.orderThan4);
                    $('.caicb_than_day4p').html((percent(o.day_caichuang_before.thanFourDay)*100).toFixed(0)+'%');
                    $('.caicb_avg').html(o.day_caichuang_before.aveDay);
                    $('.caicb_not_compelte').html(o.day_caichuang_before.notCompleteCount);$('.caicb_not_compelte').attr('href','{:url()}?a=stat&orders='+o.day_caichuang_before.notCompleteOrder);
                    $('.caicb_not_compeltep').html((percent(o.day_caichuang_before.notCompleteCount)*100).toFixed(0)+'%');
                    //裁床时效
                    $('.caic_day1').html(o.day_caichuang.oneDay);$('.caic_day1').attr('href','{:url()}?a=stat&orders='+o.day_caichuang.order1);
                    $('.caic_day1p').html((percent(o.day_caichuang.oneDay)*100).toFixed(0)+'%');
                    $('.caic_day2').html(o.day_caichuang.twoDay);$('.caic_day2').attr('href','{:url()}?a=stat&orders='+o.day_caichuang.order2);
                    $('.caic_day2p').html((percent(o.day_caichuang.twoDay)*100).toFixed(0)+'%');
                    $('.caic_day3').html(o.day_caichuang.threeDay);$('.caic_day3').attr('href','{:url()}?a=stat&orders='+o.day_caichuang.order3);
                    $('.caic_day3p').html((percent(o.day_caichuang.threeDay)*100).toFixed(0)+'%');
                    $('.caic_day4').html(o.day_caichuang.fourDay);$('.caic_day4').attr('href','{:url()}?a=stat&orders='+o.day_caichuang.order4);
                    $('.caic_day4p').html((percent(o.day_caichuang.fourDay)*100).toFixed(0)+'%');
                    $('.caic_than_day4').html(o.day_caichuang.thanFourDay);$('.caic_than_day4').attr('href','{:url()}?a=stat&orders='+o.day_caichuang.orderThan4);
                    $('.caic_than_day4p').html((percent(o.day_caichuang.thanFourDay)*100).toFixed(0)+'%');
                    $('.caic_avg').html(o.day_caichuang.aveDay);
                    $('.caic_not_compelte').html(o.day_caichuang.notCompleteCount);$('.caic_not_compelte').attr('href','{:url()}?a=stat&orders='+o.day_caichuang.notCompleteOrder);
                    $('.caic_not_compeltep').html((percent(o.day_caichuang.notCompleteCount)*100).toFixed(0)+'%');
                    //缝前时效
                    $('.chejb_day1').html(o.day_chejian_before.oneDay);$('.chejb_day1').attr('href','{:url()}?a=stat&orders='+o.day_chejian_before.order1);
                    $('.chejb_day1p').html((percent(o.day_chejian_before.oneDay)*100).toFixed(0)+'%');
                    $('.chejb_day2').html(o.day_chejian_before.twoDay);$('.chejb_day2').attr('href','{:url()}?a=stat&orders='+o.day_chejian_before.order2);
                    $('.chejb_day2p').html((percent(o.day_chejian_before.twoDay)*100).toFixed(0)+'%');
                    $('.chejb_day3').html(o.day_chejian_before.threeDay);$('.chejb_day3').attr('href','{:url()}?a=stat&orders='+o.day_chejian_before.order3);
                    $('.chejb_day3p').html((percent(o.day_chejian_before.threeDay)*100).toFixed(0)+'%');
                    $('.chejb_day4').html(o.day_chejian_before.fourDay);$('.chejb_day4').attr('href','{:url()}?a=stat&orders='+o.day_chejian_before.order4);
                    $('.chejb_day4p').html((percent(o.day_chejian_before.fourDay)*100).toFixed(0)+'%');
                    $('.chejb_than_day4').html(o.day_chejian_before.thanFourDay);$('.chejb_than_day4').attr('href','{:url()}?a=stat&orders='+o.day_chejian_before.orderThan4);
                    $('.chejb_than_day4p').html((percent(o.day_chejian_before.thanFourDay)*100).toFixed(0)+'%');
                    $('.chejb_avg').html(o.day_chejian_before.aveDay);
                    $('.chejb_not_compelte').html(o.day_chejian_before.notCompleteCount);$('.chejb_not_compelte').attr('href','{:url()}?a=stat&orders='+o.day_chejian_before.notCompleteOrder);
                    $('.chejb_not_compeltep').html((percent(o.day_chejian_before.notCompleteCount)*100).toFixed(0)+'%');
                    
                    function per(num,count){
                        b=num/count ? num/count:0;
                        a=(b).toFixed(2);
                        return a;
                    }
                    //面料打标时效
                    $('.fmg_time12').html(m.fabric_make_tag.time12);$('.fmg_time12').attr('href','{:url()}?a=stat&orders='+m.fabric_make_tag.materialOrder12);
                    $('.fmg_time12p').html((per(m.fabric_make_tag.time12,m.fabric_make_tag.timeCount)*100).toFixed(0)+'%');
                    $('.fmg_time24').html(m.fabric_make_tag.time24);$('.fmg_time24').attr('href','{:url()}?a=stat&orders='+m.fabric_make_tag.materialOrder24);
                    $('.fmg_time24p').html((per(m.fabric_make_tag.time24,m.fabric_make_tag.timeCount)*100).toFixed(0)+'%');
                    $('.fmg_time36').html(m.fabric_make_tag.time36);$('.fmg_time36').attr('href','{:url()}?a=stat&orders='+m.fabric_make_tag.materialOrder36);
                    $('.fmg_time36p').html((per(m.fabric_make_tag.time36,m.fabric_make_tag.timeCount)*100).toFixed(0)+'%');
                    $('.fmg_time48').html(m.fabric_make_tag.time48);$('.fmg_time48').attr('href','{:url()}?a=stat&orders='+m.fabric_make_tag.materialOrder48);
                    $('.fmg_time48p').html((per(m.fabric_make_tag.time48,m.fabric_make_tag.timeCount)*100).toFixed(0)+'%');
                    $('.fmg_than_time48').html(m.fabric_make_tag.thanTime48);$('.fmg_than_time48').attr('href','{:url()}?a=stat&orders='+m.fabric_make_tag.materialOrdeThan48);
                    $('.fmg_than_time48p').html((per(m.fabric_make_tag.thanTime48,m.fabric_make_tag.timeCount)*100).toFixed(0)+'%');    
                    $('.fmg_avg').html(m.fabric_make_tag.aveHour);
                    $('.fmg_not_compelte').html(m.fabric_make_tag.notCompleteMaterialCount);$('.fmg_not_compelte').attr('href','{:url()}?a=stat&orders='+m.fabric_make_tag.notCompleteMaterialOrder);
                    $('.fmg_not_compeltep').html((per(m.fabric_make_tag.notCompleteMaterialCount,m.fabric_make_tag.timeCount)*100).toFixed(0)+'%');
                     //辅料打标时效
                    $('.amg_time12').html(m.accessories_make_tag.time12);$('.amg_time12').attr('href','{:url()}?a=stat&orders='+m.accessories_make_tag.materialOrder12);
                    $('.amg_time12p').html((per(m.accessories_make_tag.time12,m.accessories_make_tag.timeCount)*100).toFixed(0)+'%');
                    $('.amg_time24').html(m.accessories_make_tag.time24);$('.amg_time24').attr('href','{:url()}?a=stat&orders='+m.accessories_make_tag.materialOrder24);
                    $('.amg_time24p').html((per(m.accessories_make_tag.time24,m.accessories_make_tag.timeCount)*100).toFixed(0)+'%');
                    $('.amg_time36').html(m.accessories_make_tag.time36);$('.amg_time36').attr('href','{:url()}?a=stat&orders='+m.accessories_make_tag.materialOrder36);
                    $('.amg_time36p').html((per(m.accessories_make_tag.time36,m.accessories_make_tag.timeCount)*100).toFixed(0)+'%');
                    $('.amg_time48').html(m.accessories_make_tag.time48);$('.amg_time48').attr('href','{:url()}?a=stat&orders='+m.accessories_make_tag.materialOrder48);
                    $('.amg_time48p').html((per(m.accessories_make_tag.time48,m.accessories_make_tag.timeCount)*100).toFixed(0)+'%');
                    $('.amg_than_time48').html(m.accessories_make_tag.thanTime48);$('.amg_than_time48').attr('href','{:url()}?a=stat&orders='+m.accessories_make_tag.materialOrdeThan48);
                    $('.amg_than_time48p').html((per(m.accessories_make_tag.thanTime48,m.accessories_make_tag.timeCount)*100).toFixed(0)+'%');    
                     $('.amg_avg').html(m.accessories_make_tag.aveHour);
                     $('.amg_not_compelte').html(m.accessories_make_tag.notCompleteMaterialCount);$('.amg_not_compelte').attr('href','{:url()}?a=stat&orders='+m.accessories_make_tag.notCompleteMaterialOrder);
                     $('.amg_not_compeltep').html((per(m.accessories_make_tag.notCompleteMaterialCount,m.accessories_make_tag.timeCount)*100).toFixed(0)+'%');
                     //批色时效
                    $('.ap_time12').html(m.time_approval_color.time12);$('.ap_time12').attr('href','{:url()}?a=stat&orders='+m.time_approval_color.materialOrder12);
                    $('.ap_time12p').html((per(m.time_approval_color.time12,m.time_approval_color.timeCount)*100).toFixed(0)+'%');
                    $('.ap_time24').html(m.time_approval_color.time24);$('.ap_time24').attr('href','{:url()}?a=stat&orders='+m.time_approval_color.materialOrder24);
                    $('.ap_time24p').html((per(m.time_approval_color.time24,m.time_approval_color.timeCount)*100).toFixed(0)+'%');
                    $('.ap_time36').html(m.time_approval_color.time36);$('.ap_time36').attr('href','{:url()}?a=stat&orders='+m.time_approval_color.materialOrder36);
                    $('.ap_time36p').html((per(m.time_approval_color.time36,m.time_approval_color.timeCount)*100).toFixed(0)+'%');
                    $('.ap_time48').html(m.time_approval_color.time48);$('.ap_time48').attr('href','{:url()}?a=stat&orders='+m.time_approval_color.materialOrder48);
                    $('.ap_time48p').html((per(m.time_approval_color.time48,m.time_approval_color.timeCount)*100).toFixed(0)+'%');
                    $('.ap_than_time48').html(m.time_approval_color.thanTime48);$('.ap_than_time48').attr('href','{:url()}?a=stat&orders='+m.time_approval_color.materialOrdeThan48);
                    $('.ap_than_time48p').html((per(m.time_approval_color.thanTime48,m.time_approval_color.timeCount)*100).toFixed(0)+'%');    
                    $('.ap_avg').html(m.time_approval_color.aveHour);
                    $('.ap_not_compelte').html(m.time_approval_color.notCompleteMaterialCount);$('.ap_not_compelte').attr('href','{:url()}?a=stat&orders='+m.time_approval_color.notCompleteMaterialOrder);
                    $('.ap_not_compeltep').html((per(m.time_approval_color.notCompleteMaterialCount,m.time_approval_color.timeCount)*100).toFixed(0)+'%');
                     //验布时效
                    $('.checkc_time12').html(m.time_checkcloth.time12);$('.checkc_time12').attr('href','{:url()}?a=stat&orders='+m.time_checkcloth.materialOrder12);
                    $('.checkc_time12p').html((per(m.time_checkcloth.time12,m.time_checkcloth.timeCount)*100).toFixed(0)+'%');
                    $('.checkc_time24').html(m.time_checkcloth.time24);$('.checkc_time24').attr('href','{:url()}?a=stat&orders='+m.time_checkcloth.materialOrder24);
                    $('.checkc_time24p').html((per(m.time_checkcloth.time24,m.time_checkcloth.timeCount)*100).toFixed(0)+'%');
                    $('.checkc_time36').html(m.time_checkcloth.time36);$('.checkc_time36').attr('href','{:url()}?a=stat&orders='+m.time_checkcloth.materialOrder36);
                    $('.checkc_time36p').html((per(m.time_checkcloth.time36,m.time_checkcloth.timeCount)*100).toFixed(0)+'%');
                    $('.checkc_time48').html(m.time_checkcloth.time48);$('.checkc_time48').attr('href','{:url()}?a=stat&orders='+m.time_checkcloth.materialOrder48);
                    $('.checkc_time48p').html((per(m.time_checkcloth.time48,m.time_checkcloth.timeCount)*100).toFixed(0)+'%');
                    $('.checkc_than_time48').html(m.time_checkcloth.thanTime48);$('.checkc_than_time48').attr('href','{:url()}?a=stat&orders='+m.time_checkcloth.materialOrdeThan48);
                    $('.checkc_than_time48p').html((per(m.time_checkcloth.thanTime48,m.time_checkcloth.timeCount)*100).toFixed(0)+'%');    
                    $('.checkc_avg').html(m.time_checkcloth.aveHour);
                    $('.checkc_not_compelte').html(m.time_checkcloth.notCompleteMaterialCount);$('.checkc_not_compelte').attr('href','{:url()}?a=stat&orders='+m.time_checkcloth.notCompleteMaterialOrder);
                    $('.checkc_not_compeltep').html((per(m.time_checkcloth.notCompleteMaterialCount,m.time_checkcloth.timeCount)*100).toFixed(0)+'%');
                     //缩水时效
                    $('.shrink_time12').html(m.time_shrink.time12);$('.shrink_time12').attr('href','{:url()}?a=stat&orders='+m.time_shrink.materialOrder12);
                    $('.shrink_time12p').html((per(m.time_shrink.time12,m.time_shrink.timeCount)*100).toFixed(0)+'%');
                    $('.shrink_time24').html(m.time_shrink.time24);$('.shrink_time24').attr('href','{:url()}?a=stat&orders='+m.time_shrink.materialOrder24);
                    $('.shrink_time24p').html((per(m.time_shrink.time24,m.time_shrink.timeCount)*100).toFixed(0)+'%');
                    $('.shrink_time36').html(m.time_shrink.time36);$('.shrink_time36').attr('href','{:url()}?a=stat&orders='+m.time_shrink.materialOrder36);
                    $('.shrink_time36p').html((per(m.time_shrink.time36,m.time_shrink.timeCount)*100).toFixed(0)+'%');
                    $('.shrink_time48').html(m.time_shrink.time48);$('.shrink_time48').attr('href','{:url()}?a=stat&orders='+m.time_shrink.materialOrder48);
                    $('.shrink_time48p').html((per(m.time_shrink.time48,m.time_shrink.timeCount)*100).toFixed(0)+'%');
                    $('.shrink_than_time48').html(m.time_shrink.thanTime48);$('.shrink_than_time48').attr('href','{:url()}?a=stat&orders='+m.time_shrink.materialOrdeThan48);
                    $('.shrink_than_time48p').html((per(m.time_shrink.thanTime48,m.time_shrink.timeCount)*100).toFixed(0)+'%');    
                    $('.shrink_avg').html(m.time_shrink.aveHour);
                    $('.shrink_not_compelte').html(m.time_shrink.notCompleteMaterialCount);$('.shrink_not_compelte').attr('href','{:url()}?a=stat&orders='+m.time_shrink.notCompleteMaterialOrder);
                    $('.shrink_not_compeltep').html((per(m.time_shrink.notCompleteMaterialCount,m.time_shrink.timeCount)*100).toFixed(0)+'%');
                }
             });
             
             /* $.ajax({
                type: "POST",
                url: "{:url('cwTimeStatistics')}",
                data: formData,
                dataType:"json",
                success: function(res){
                    var o=res.order,m=res.material;
                }
            }); */    
       });
		form.render();
        //数据统计弹窗操作start
        var where=where1="";
        var hreStr=window.location.search;
        if(hreStr.indexOf("stat") != -1){
            $(".removeStat").remove();            
            where1=window.location.search+"&create_date_range="+$.cookie('create_date_range')+"&factory_id="+$.cookie('factory_id')+"&sku="+$.cookie('sku')+"&caichuang_over_date_range="+$.cookie('caichuang_over_date_range')+"&order_status="+$.cookie('order_status')+"&over_date_range="+$.cookie('over_date_range')+"&is_auto_import="+$.cookie('is_auto_import');
            where=where1+"&client_ordernum="+$.cookie('client_ordernum');
            $("#hisi-table-search-optable").attr("action",where1);
        }else{
            where="?a=stat";
        }
        //数据统计弹窗操作over
		laydate.render({
		    elem: '#create_date_range'
		    ,range: '~'
		    ,theme: 'molv'
		    ,mark: {'{:$today}':''}
	    	,change: function(value, date, endDate){
		    	$('#create_date_range').val(value);
            	$('#layui-laydate1').remove();//关闭面板
            }
		});
		
		var opTable = layui.opTable.render({
			elem : '#dataTable'
			,url : "{:url()}"+where
			,page: true
			,limit: 20
            ,limits: [20,50,100,150,200]
            ,text: {
                none : '暂无相关数据'
            }
			,toolbar: '#toolbar'
	        ,defaultToolbar: ['filter', 'exports', 'print']
			,cols : [[ 
				{field:'pic',title : '图片', templet:'#picTpl',width:110}
				,{field:'client_ordernum',title : '订单号/SKU/时效', templet:'#skuTpl',width:200}
				,{field:'factory_id',title : '工厂/分组', templet:'#factoryTpl',width:150}
				,{field:'order_num',title : '下单 / 裁床 / 车间 / 后整 / 打包 / 出货', templet:'#orderNumTpl',width:240}
				,{field:'order_num',title : '可用库存', templet:'#skuStockTpl',width:120}
				,{field:'order_time',title : '时间进度', templet:'#orderTimeTpl',width:220}
				,{field:'order_user',title : '采购执行人', templet:'#orderUserTpl',width:150}
				,{field:'caigou_remark',title : '采购备注',edit:'text',style:'border-bottom:2px dotted #5FB878;',width:200}
				,{field:'btn',title : '操作',templet:'#buttonTpl',width:120}
			]]

			,onEdit: function(obj,res) {
				var value = obj.value //得到修改后的值
			    ,data = obj.data //得到所在行所有键值
			    ,field = obj.field; //得到字段
			    
			    // 编辑备注
			    if (field == 'caigou_remark') {
			    	$.ajax({
			 		   type: "POST",
			 		   url: "{:url('remark')}",
			 		   data: "order_id="+data.id+"&remark="+value,
			 		   dataType:"json",
			 		   success: function(res){
			 			  if (res.code == 1) {
							 layer.msg(res.msg, {icon: 1});
						  } else {
							 layer.msg(res.msg, {icon: 2,anim: 6});
						  }
			 		   }
			 		});
			    }
			}
			
			//  展开的列配置
			,openTable: function (itemData) {
				return {
					elem: '#child' + itemData.LAY_INDEX
					,id: 'child' + itemData.LAY_INDEX
					,data: layui.tool.setDataToList(itemData, itemData.omList)
					,cellMinWidth: 100
                    ,limit: 20
					,toolbar: false
				    //,defaultToolbar: ['filter', 'exports', 'print']
					,cols: [[
						{field: 'name', title: '材料名称',width:160,templet:function(d){return layui.tool.formatMaterialType(d.mInfo.type, '', 2) + '<span class="copy-item">' + d.mInfo.name + '</span> <br>sku：<span class="copy-item">' + d.mInfo.material_sku+'</span>';}}
						,{field:'model',title : '型号',templet:function(d){return d.mInfo.model;}}
						,{field:'colornum',title : '色号',width:60,templet:function(d){return d.mInfo.colornum;}}
						,{field:'color',title : '颜色',width:60,templet:function(d){return d.mInfo.color;}}
						,{field:'supplier',title : '供应商',width:100,templet:function(d){return "<a href='javascript:void(0);' class='supplier' data-supplier='"+d.mInfo.supplier+"' data-address='"+d.mInfo.address+"' data-contact='"+d.mInfo.contact+"'>"+d.mInfo.supplier+"</a>";}}
						,{field:'fabric_width',title : '幅宽/克重/米',width:120,templet:function(d){return d.fabric_width+' / '+d.weight+' / '+layui.tool.bcdiv(100000, d.fabric_width*d.weight)+'<br>';}}
                        ,{field:'jing_material_dosage',title : '净用量',width:60}
						,{field:'total_material_dosage',title : '总用量',width:60}
						,{field:'col1',title : '余料已/未使用',templet:'#subMaterialUseTpl',width:80}
						,{field:'col2',title : '物料状态',templet:'#purchasingStatusTpl',width:140}
						//,{field:'col3',title : '库存/占用量',templet:'#leftUseTpl',width:60}
						,{field:'col4',title : '还需用量',width:60,templet:'#needNumTpl'}
						,{field:'caigou_unitprice',title : '单价',width:60}
						,{field:'shiji_caigou_count',title : '总条数',width:60,templet:'#shijiCaigouTpl'}
						,{field:'tiaoshu_detail',title : '条数明细',width:80,templet:'#tiaoshuDetailTpl'}
						,{field:'return_length',title : '退料(米)',width:60}
						,{field:'purchasing_unit',title : '单位',width:40,templet:function(d){return d.mInfo.purchasing_unit;}}
						,{field:'subbtn',title : '操作',templet:'#subButtonTpl',width:305}
					]]
		        }
		      }
			,openType : 1
			,done: function(res, curr, count){
				opTable.openAll();
                $(".layui-table-page div .layui-box").append("<span>共&nbsp;"+res.skuCount+"&nbsp;款</span> <span>&nbsp;&nbsp;|&nbsp;&nbsp;</span> &nbsp;<span>共&nbsp;"+res.allQuantity+"&nbsp;件</span>");
				if (res.stat !== undefined) {
					var p = res.stat;
					var w = res.stat.detailWhere;

					$.cookie("client_ordernum",w.client_ordernum,{ path:"/" });
					$.cookie("create_date_range",w.create_date_range,{ path:"/" });
					$.cookie("factory_id",w.factory_id,{ path:"/" });
					$.cookie("caichuang_over_date_range",w.caichuang_over_date_range,{ path:"/" });
					$.cookie("order_status",w.order_status,{ path:"/" });
					$.cookie("over_date_range",w.over_date_range,{ path:"/" });
					$.cookie("sku",w.sku,{ path:"/" });
					$.cookie("is_auto_import",w.is_auto_import,{ path:"/" });

					$('.ac-item').html(p.allCount);
					$('.stat-fcoc-item').html(p.fabricCgOverCount);
					$('.stat-fcnc-item').html(p.fabricCgNotCount);
                    $('.stat-rmc-item').html(p.returnMaterialCount);
					$('.stat-acoc-item').html(p.apColorOverCount);
					$('.stat-acnc-item').html(p.apColorNotCount);
					$('.stat-acnoc-item').html(p.apColorNoCount);
					$('.stat-csoc-item').html(p.ckClothSkOverCount);
					$('.stat-csnc-item').html(p.ckClothSkNotCount);
					$('.stat-coc-item').html(p.caichuangOverCount);
					$('.stat-cnc-item').html(p.caichuangNotCount);
					$('.stat-aoc-item').html(p.acOverCount);
					$('.stat-anc-item').html(p.acNotCount);
					$('.stat-acNoCount-item').html(p.acNoCount);

					$('.stat-fcocp-item').html(p.fabricCgOverCountPer);
                    $('.stat-rmcp-item').html(p.returnMaterialCountPer);
					$('.stat-fncp-item').html(p.fabricCgNotCountPer);
					$('.stat-acocp-item').html(p.apColorOverCountPer);
                    $('.stat-rmcps-item').html(p.returnMaterialCountPer);
					$('.stat-acncp-item').html(p.apColorNotCountPer);
					$('.stat-acnocp-item').html(p.apColorNoCountPer);
					$('.stat-csocp-item').html(p.ckClothSkOverCountPer);
					$('.stat-csncp-item').html(p.ckClothSkNotCountPer);
					$('.stat-cocp-item').html(p.caichuangOverCountPer);
					$('.stat-cncp-item').html(p.caichuangNotCountPer);
					$('.stat-aocp-item').html(p.acOverCountPer);
					$('.stat-ancp-item').html(p.acNotCountPer);
					$('.stat-acNoCountp-item').html(p.acNoCountPer);
				}
			}
		});
		
		// 更新物料状态
		window.updateMaterialStatus = function(mid) {
			$.ajax({
		 		   type: "POST",
		 		   url: "{:url('getMaterialStatus')}",
		 		   data: "mid="+mid,
		 		   dataType:"json",
		 		   success: function(res){
		 			  if (res.code == 1) {
		 				 var Tpl = $('#purchasingStatusTpl').html().replace(/material-status/g, '');
						 laytpl(Tpl).render(res.data, function(html){
						   	$('.material-status-'+mid).html(html);
						 });
					  } else {
						  opTable.reload();
					  }
		 		   }
		 	});
		}
		
		// 设置采购执行人
		$(document).on('change','.caigou-user',function(){
			var caigouUserId = $(this).val();
			var orderId = $(this).attr('data-key');
			if (caigouUserId > 0) {
				$.ajax({
		 		   type: "POST",
		 		   url: "{:url('setCaigouUser')}",
		 		   data: "caigou_user_id="+caigouUserId+"&order_id="+orderId,
		 		   dataType:"json",
		 		   success: function(res){
		 			  if (res.code == 1) {
						 layer.msg(res.msg, {icon: 1});
					  } else {
						 layer.msg(res.msg, {icon: 2,anim: 6});
					  }
		 		   }
		 		});
			}
		});
		
		// 辅料开始采购
		$(document).on('click','.start-purchasing',function(){
			var orderId = $(this).attr('data-order_id');
			var materialId = $(this).attr('data-material_id');
			var mid = $(this).attr('data-mid');
			$.ajax({
	 		   type: "POST",
	 		   url: "{:url('distributingFeed/startPurchasing')}",
	 		   data: "order_id="+orderId+"&material_id="+materialId,
	 		   dataType:"json",
	 		   success: function(res){
	 			  if (res.code == 1) { // 使用库存完成采购
					 layer.msg(res.msg, {icon: 1});
					 updateMaterialStatus(mid);
	 			  } else if(res.code == 2) {
	 				 layer.msg(res.msg, {icon: 1,end:function(){
						 if(res.data.info != '') layui.tool.copyText(res.data.info);
					 }});
	 				 updateMaterialStatus(mid);
				  } else {
					 layer.msg(res.msg, {icon: 2,anim: 6});
				  }
	 		   }
	 		});
		});
		
		// 面料开始采购
		$(document).on('click','.start-purchasing-metre',function(){
			var orderFrom = $(this).attr('data-order_from');
			var clientOrdernum = $(this).attr('data-client_ordernum');
			var name = $(this).attr('data-name');
			var colornum = $(this).attr('data-colornum');
			var color = $(this).attr('data-color');
			var num = $(this).attr('data-num');
			var orderId = $(this).attr('data-order_id');
			var materialId = $(this).attr('data-material_id');
			var mid = $(this).attr('data-mid');
			var model = $(this).attr('data-model');
            var sku=$(this).attr('data-sku');
			var weight=$(this).attr('data-weight');
			$.ajax({
		 		   type: "POST",
		 		   url: "{:url('purchasing/startPurchasing')}",
		 		   data: "order_id="+orderId+"&material_id="+materialId,
		 		   dataType:"json",
		 		   success: function(res){
		 			  if (res.code == 1) {
		 			  	 updateMaterialStatus(mid);
		 			  } else {
						 layer.msg(res.msg, {icon: 2,anim: 6});
					  }
		 		   }
		 	});
			
			msg = orderFrom + " \\ " + clientOrdernum + " \\ " + sku + " \\ 克重" + weight + " \\ " + name + " \\ "+colornum+" \\ "+color+" \\ "+num+" \\ "+model;
			layui.tool.copyText(msg);
		});
		
		// 供应商点击
		$(document).on('click','.supplier',function(){
			var content = $(this).attr('data-supplier') +"<br>"+ $(this).attr('data-contact') +"<br>"+ $(this).attr('data-address')
			layer.tips(content, this);
		});
		// 到料
		window.arriveTime = function(mid) {  
            $.ajax({
                type: "POST",
                url: "{:url('purchasing/arriveTime')}",
                data: "mid="+mid,
                dataType:"json",
                success: function(res){
                   if (res.code == 1) {
                       $('.arrive-time-'+mid).html("更新");
                       $('.arrive-time-'+mid).addClass("layui-btn-warm");
                       $('.make-tag-'+mid).attr("style", "display:;");
                       layer.msg(res.msg, {icon: 1,anim: 6});
                   } else {
                      layer.msg(res.msg, {icon: 2,anim: 6});
                   }
                }
            });
        }
		// 打标
		$(document).on('click','.make-tag',function(){
			var mid = $(this).attr('data-mid');
			var layerMakeTag = layer.open({
				type: 1
				,shade: 0
				,offset: '100px'
				,anim: parseInt(Math.random()*(6+1),10)
				,skin:'layui-layer-molv'
				,title:'打标'
				,content: $('#makeTagTpl')
                ,area: ['420px', '550px'] //宽高
				,success: function(layero, index){
				    $('input[name=number]').focus();
				}
				,btn: ['保存并打印']
				,yes: function(index, layero){
					var number = $('#makeTagTpl form input[name=number]').val();
					if(!(/^\d+$/.test(number))){
						layer.msg('条数输入错误', {icon: 2,anim: 6});
						return;
					}
			    	data = $('#makeTagTpl form').serialize();
			    	$.ajax({
			 		   type: "POST",
			 		   url: "{:url('makeTag')}",
			 		   data: data+"&mid="+mid,
			 		   dataType:"json",
			 		   success: function(res){
			 			  if (res.code == 1) {
							 layer.msg(res.msg, {icon: 1});
							 $('#makeTagTpl form')[0].reset();
							 layer.close(layerMakeTag);
							 opTable.reload();
							 window.open(res.data.url);
						  } else {
							 layer.msg(res.msg, {icon: 2,anim: 6});
						  }
			 		   }
			 		});
				}
			});
		});
		
		// 批色
		$(document).on('click','.approval-color',function(){
			var mid = $(this).attr('data-mid');
			var order_id = $(this).attr('data-order_id');
			var layerApprovalColor = layer.open({
				type: 1
				,shade: 0
				,offset: '100px'
				,anim: parseInt(Math.random()*(6+1),10)
				,skin:'layui-layer-molv'
				,title:'批色'
				,content: $('#approvalColorTpl')
				,success: function(layero, index){
				}
				,btn: ['确认']
				,yes: function(index, layero){
			    	data = $('#approvalColorTpl form').serialize();
			    	$.ajax({
			 		   type: "POST",
			 		   url: "{:url('approvalColor')}",
			 		   data: data+"&mid="+mid+"&order_id="+order_id,
			 		   dataType:"json",
			 		   success: function(res){
			 			  if (res.code == 1) {
							 layer.msg(res.msg, {icon: 1});
							 $('#approvalColorTpl form')[0].reset();
							 layer.close(layerApprovalColor);
							 
							 if(layui.tool.getQueryString(data, 'status') == 2) {
								 $(".approval-color-"+mid).attr('title', '批色未通过');
								 $(".approval-color-"+mid).html('批色未通过');
							 } else {
								 $(".approval-color-"+mid).remove();
							 }
							 
						  } else {
							 layer.msg(res.msg, {icon: 2,anim: 6});
						  }
			 		   }
			 		});
				}
			});
		});
		
		// 入库后更新库存数
		window.updateStock = function(mid, num) {
			//console.log(mid+'-'+num);
			var oriNum = layui.tool.parseFloat($('.stock-'+mid).html());
			$('.stock-'+mid).html(layui.tool.bcadd(num, oriNum));
		}
		
		// 全部批色后回调
		window.callbackApprovalColor = function(obj, res) {
			if (res.code == 1) {
				obj.remove();
				if (res.data.is_all_over == 1) {
					var orderId = res.data.order_id;
					$('.approval-color-'+orderId).remove();
				}
			}
		}
		/**
	     * layui非静态table搜索渲染
	     * @attr data-table table容器ID
	     * @attr hisi-data table基础参数
	     * @attr action 搜索请求地址
	     */
	   $(document).on('submit', '#hisiSearchOpTable,#hisi-table-search-optable', function() {
	        var that = $(this), 
	            arr = that.serializeArray(),
	            where = new Array(),
	            dataTable = that.attr('data-table') ? that.attr('data-table') : 'dataTable',
	            options = new Function('return '+ that.attr('hisi-data'))() || {page: {curr:1}};
	        
	            for(var i in arr) {
	                where[arr[i].name] = arr[i].value;
	            }
	        
	        options.url = that.attr('action');
	        options.where = where;
	        
	        opTable.reload(options);
	        return false;
	    });
		window.callbackAudit = function(obj, res) {
			//console.log(res);
			if (res.code == 1) {
                $("#layui-table-page1 .layui-box").append("<span>共&nbsp;"+res.skuCount+"&nbsp;款</span> <span>&nbsp;&nbsp;|&nbsp;&nbsp;</span> &nbsp;<span>共&nbsp;"+res.allQuantity+"&nbsp;件</span>");
                
            }
        }
        //增加新增
        $('.stall-select .layui-anim-upbit').append("<a href='{:url('Stalls/add')}' hisi-data='{}' style='margin-left:55px' class='layui-btn hisi-iframe'>去新增</a>");
        
	});
    
</script>